package com.Example.Dao;

import com.Example.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Cheng-02
 * @version V1.0
 * @Package com.Example.Dao
 * @date 2024/4/22 下午1:38
 */
@Repository
public class StudentDaoImpl implements StudentDao{
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Override
    public List<Student> queryAll() {

        String sql="SELECT  id,name, age,gender,age,class as classes FROM students;";
        List<Student> query = jdbcTemplate.query("SELECT  id,name, age,gender,age,class as classes FROM students;", new BeanPropertyRowMapper<Student>(Student.class));

        return query;
    }
}
